/**
 @文件名： messageUnits
 @来源：YongPing.Wang|2023/11/17 21:36
 @描述：消息弹框通用设置
 **/
import { ElMessage } from 'element-plus'

// 成功
export const msgSuccess = function (value: string = '', duration: number = 3000): void {
  if (value !== '') {
    showMessage(value, 'success', duration)
  }
}
// 失败
export const msgError = function (value: string = '', duration: number = 3000): void {
  if (value !== '') {
    showMessage(value, 'error', duration)
  }
}
// 警告
export const msgWarning = function (value: string = '', duration: number = 3000): void {
  if (value !== '') {
    showMessage(value, 'warning', duration)
  }
}
// 消息
export const msgInfo = function (value: string = '', duration: number = 3000): void {
  if (value !== '') {
    showMessage(value, 'info', duration)
  }
}
// 展示消息
export const showMessage = function (message: string, type: string = 'error', duration: number = 3000): void {
  ElMessage({
    message,
    type,
    showClose: true,
    duration,
    grouping: true,
  } as any)
}
